<template>
	<div id="meal_fee_manage" class="container">
		<div class="content">
			<!-- <div class="title">{{title}}</div> -->
			<div class="panel">
				<div>
					<table class="table" cellspacing="0">
						<thead class="thead">
							<tr>
								<td style="width: 2rem;">餐费名</td>
								<td style="width: 4rem;">定价（元/天）</td>
								<td style="width: 2rem;">收费规则</td>
								<td style="width: 2rem;">退费规则</td>
								<td style="width: 2rem;">修改人</td>
								<td style="width: 2rem;">最后修改时间</td>
								<td style="width: 2rem;">操作</td>
							</tr>
						</thead>
						<tbody class="tbody">
							<tr v-for="item,index in mealFeeList">
								<td>{{item.name}}</td>
								<td>{{item.salesPrice}}</td>
								<td>{{item.chargeRule}}</td>
								<td>{{item.refundRule}}</td>
								<td>{{item.updateUserName}}</td>
								<td>{{item.updateTime}}</td>
								<td>
									<span class="operate_btn" v-if="hasApi('mealFeeUpdate')" @click="openEdit(item)">编辑</span>
									&nbsp;
									<span class="operate_btn" v-if="hasApi('mealFeeLog')" @click="openLog(item.mealsId)">更新日志</span>
								</td>
							</tr> 
						</tbody>
					</table>
				</div>
			</div>
		</div>
		
		<mealFeeEdit ref="mealFeeEdit" @callback="closeEdit"></mealFeeEdit>
		<mealFeeLog ref="mealFeeLog"></mealFeeLog>
	</div>
</template>

<script>
	
import mealFeeEdit from './common/meal_fee_edit'
import mealFeeLog from './common/meal_fee_log'
	
var vm,dict;
export default {
	components : {
		mealFeeEdit,mealFeeLog
	},
	data : function() {
		return {
			title : this.$route.name,
			param : {
				campusId : this.$store.state.campusId,
			},
			count : null,
	        mealFeeList : [{type:1},{type:2, refundType:1}],
	        
		}
	},
	methods : {
		search : function(currPage) {
			
			api.mealFeeList(vm.param).then(function(data) {
				data.list.forEach(function(item) {
					if(item.type == 1) {
						item.chargeRule = "预收费";
					}
					if(item.type == 2) {
						item.chargeRule = "先记账，后结算";
					}
					if(item.refundRulesMode == 0) {
						item.refundRule = "不退费";
					}
					if(item.refundRulesMode == 1) {
						item.refundRule = "连续请假" + item.refundRulesDay + "天，退餐费";
					}
				});
				vm.mealFeeList = data.list;
			})
		},
		campusChange : function(campusId) { //校区改变
			vm.param.campusId = campusId;
			vm.search();
		},
		openEdit : function(mealFee) {
			vm.$refs.mealFeeEdit.init(mealFee);
		},
		closeEdit : function() {
			vm.search();
		},
		openLog : function(id) {
			vm.$refs.mealFeeLog.init(id);
		},
	},
	mounted : function() {
		
	},
	created : function() {
		vm = this;
		//请求列表数据
		vm.search();
		
		//获取数据字典对象
		dict = tool.getItem(lsKey.dict,true);
	}
}

</script>

<style lang="scss">
	#meal_fee_manage {
		.el-input__inner {
			border-radius: 0.08rem;
			font-size: 0.16rem;
			color: #666666;
			height: 0.36rem;
			line-height: 0.36rem;
		}
		.el-input__icon {
			line-height: 0.36rem;
		}
	}
</style>
<style scoped src="@/style/module/table.css"></style>
<style scoped src="@/style/clue_manage/clue_manage.css"></style>
